#! /bin/sh

# build sata specific branch software version
# changes:
#	copy ata drivers to board
#	modify qqzm_start.sh to modprobe ahci module
#	use /dev/sda* device name in sdmng.c file.
# must run on the board after mount /home/lzhong using nfs


# DVR_ROOT=/home/lzhong/work/dvr/software
# mount /home/lzhong  to board /tmp directory
DVR_ROOT=/tmp/work/dvr/software
BOARD_DRV_ROOT=/lib/modules/2.6.24-rt1-hi3515v100/kernel/drivers/
BOARD_KERNEL_REV=2.6.24-rt1-hi3515v100

KERNL_REV=$(uname -r)
if [ $KERNL_REV = $BOARD_KERNEL_REV ]
then
	#	copy ata drivers to board and modprobe ahci
	cp -a $DVR_ROOT/kernel/drivers/ata $BOARD_DRV_ROOT
	modprobe nls_ascii
	modprobe ahci

	#	modify qqzm_start.sh to modprobe ahci module
	cp $DVR_ROOT/scripts/sata_qqzm_start.sh /qqzm/scripts/qqzm_start.sh
	# add umount all mounted sata or sd card
	cp $DVR_ROOT/scripts/stop_app.sh /qqzm/scripts/stop_app.sh

	#	use /dev/sda* device name in sdmng.c file.
	# make clean && make SATA=yes && make strip 
	if [ -f $DVR_ROOT/dvr/dvr ]
	then
		rm /qqzm/bin/dvr
		cp $DVR_ROOT/dvr/dvr /qqzm/bin/dvr
	else
		echo "error:no sata dvr !"
		exit 1
	fi
else
	echo "error:must run on the board after mount /home/lzhong to /tmp using nfs."
	exit 2
fi

echo "finish sata branch changes."
exit 0

